package com.garlicts.excel;

import org.springframework.context.ApplicationContext;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class CargoVerifyHandlerImpl implements GarlictsExcelVerifyHandler<CargoImportPojo> {
	
	@Override
	public Map<String, String> verify(CargoImportPojo obj, int currRowNum, Map<String, Integer> fieldColumnNumMap, ApplicationContext applicationContext) {
		
		Map<String, String> errorMap = new HashMap<String, String>();

		try {
			String loadArea = obj.getLoadArea();
			System.out.println("loadArea="+loadArea);

			StringBuilder stringBuilder = new StringBuilder();
			Integer currColumnNum = fieldColumnNumMap.get("loadArea");
			stringBuilder.append(currRowNum).append("_").append(currColumnNum);

			if(Objects.equals(loadArea, null)) {
				errorMap.put(stringBuilder.toString(), "装货地区未填写");
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}		
		
		return errorMap;
		
	}

	@Override
	public String execute(CargoImportPojo cargoImportPojo, int currRowNum, Map<String, Integer> fieldColumnNumMap, ApplicationContext applicationContext) {
		return null;
	}

}
